﻿/* 
 * Copyright (c) 2011 Jeff Zhang
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of 
 * this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, 
 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
 * and to permit persons to whom the Software is furnished to do so, 
 * subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included 
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace Json {
    internal interface IJsonReader {
        /// <summary>
        /// Read a number from text stream.
        /// Example: 
        ///     int:11, +234, -325; 
        ///     long:2345667L
        ///     float:(+/-)11.33f, 23.455e+4, 2456.345e-2; 
        ///     double:234.4455
        /// </summary>
        /// <returns>JsonInt, JsonInt64, JsonFloat or JsonDouble</returns>
        Number ReadNumber();

        /// <summary>
        /// Read a bool value from text stream.
        /// The form is true or false which is casesensitive.
        /// </summary>
        /// <returns>JsonBoolean</returns>
        bool ReadBoolean();

        /// <summary>
        /// Read a string from text stream.
        /// The string is the form which beigns with single or double quote, 
        /// and end with single or double quote. Such as
        /// 'I can\' do it.' or "I can't do it."
        /// </summary>
        /// <returns>JsongString</returns>
        string ReadString();

        /// <summary>
        /// Read a datetime value from text stream.
        /// The DateTime is the form which beigns with angle bracket, 
        /// and ends with angle bracket.
        /// Such as <![CDATA[
        /// <2010/9/10 12:34:22>
        /// ]]>
        /// </summary>
        /// <returns>JsonDateTime</returns>
        DateTime ReadDateTime();

        /// <summary>
        /// Read an array from text stream.
        /// The array is the form which begins with square bracket,
        /// and ends with square bracket.
        /// Such as [23,456, 23], ['guangbo', 'zhanggb', 'jeff'] or [true, false, true].
        /// </summary>
        /// <returns>JsonArray</returns>
        JsonArray ReadArray();

        /// <summary>
        /// Read an array from text stream.
        /// The array is the form which begins with square bracket,
        /// and ends with square bracket.
        /// Such as [23,456, 'hi, how are you?', <2010-3-4 23:21:22>, {}]
        /// The array item can be any json type, such as int, long, 
        /// string, bool, datetime, object(dictionary).
        /// </summary>
        /// <returns></returns>
        //IJsonObject ReadTuple();

        /// <summary>
        /// Read a dictionary from text stream.
        /// The dict is the form which begins with brace bracket,
        /// and ends with brace bracket.
        /// Such as {'Name':'guangboo', 'Age':23, 'Borth':<1980-1-07>}
        /// </summary>
        /// <returns>JsonDictionay</returns>
        JsonDictionary ReadDictionay();

        /// <summary>
        /// Read a null value from text stream.
        /// That is a string form, just a word null, and it
        /// is casesensitive.
        /// </summary>
        /// <returns>JsonNull</returns>
        JsonNull ReadNull();
    }
}
